package com.yamibuy.ec.resource.handler;

import com.yamibuy.ec.resource.exception.PathUnknowException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;

import javax.servlet.ServletResponse;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Set;

/**
 * 根据path选择需要处理的handler
 *
 * @author: damon.li
 * @version: 2021年02月24日 11:15
 */
@Component
public class HandleSelector {

	@Autowired
	private List<RequestHandlerFlag> requestHandler;

	public RequestHandlerFlag selector(String path){
		for (RequestHandlerFlag handler : requestHandler) {
			if(handler.flag(path)){
				return handler;
			}
		}
		throw new PathUnknowException("该path不能识别处理，请检查图片程序");
	}

}
